#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int fun(int n)
{
    int count = 0;

    for (int i = 0; i <= n; ++i)
    {
        int squar = i * i;
        int flag = 1;
        int x = i;
        while (x)
        {
            if (squar % 10 != x % 10)
            {
                flag = 0;
                break;
            }
           
            x /= 10;
            squar /= 10;
   

        }
        if (flag)
        {
            ++count;
        }

    }
    return count;

}
int main() {
    int n = 0;
    scanf("%d", &n);
    int ret = fun(n);
    printf("%d\n",ret);
    
    return 0;
}